package org.nanotek.spring.tika;

import java.util.Iterator;

import org.apache.tools.ant.DirectoryScanner;
import org.nanotek.tika.fs.RootDirectories;
import org.springframework.beans.factory.InitializingBean;

public class DirectoryContextScanner extends DirectoryScanner implements InitializingBean
{

	private RootDirectories rootDirectories; 
	
	public DirectoryContextScanner() {}

	@Override
	public void afterPropertiesSet() throws Exception {}

	public RootDirectories getRootDirectories() {
		return rootDirectories;
	}

	public void setRootDirectories(RootDirectories rootDirectories) {
		this.rootDirectories = rootDirectories;
	}
	
	@Override
	public void scan() throws IllegalStateException {
		Iterator<String> it = rootDirectories.getRootDirectorySet().iterator(); 
		while (it.hasNext()){
			setBasedir(it.next());
			super.scan();
		}
	}
	
}
